package com.xhsj.user.hr.process.processDefinition.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.base.Joiner;
import com.xhsj.user.hr.base.BaseService;
import com.xhsj.user.hr.process.dto.PageDto;
import com.xhsj.user.hr.process.dto.processDefinition.HandleAuditDto;
import com.xhsj.user.hr.process.hrLeaveProcess.query.FirstProcessNodeIdQuery;
import com.xhsj.user.hr.process.processDefinition.entity.TbGlobalApprovalHiTask;
import com.xhsj.user.hr.process.processDefinition.entity.TbGlobalApprovalTask;
import com.xhsj.user.hr.process.processDefinition.entity.TbGlobalWorkFlowNode;
import com.xhsj.user.hr.process.processDefinition.mapper.TbGlobalApprovalHiTaskMapper;
import com.xhsj.user.hr.process.processDefinition.mapper.TbGlobalApprovalTaskMapper;
import com.xhsj.user.hr.process.processDefinition.mapper.TbGlobalWorkFlowNodeMapper;
import com.xhsj.user.hr.process.processDefinition.query.HrMessageQuery;
import com.xhsj.user.hr.process.processDefinition.query.ProcessNodeQuery;
import com.xhsj.user.hr.process.processDefinition.query.TbGlobalWorkFlowNodoJudgeQuery;
import com.xhsj.user.security.entity.LoginUser;
import com.xhsj.user.hr.system.mapper.TbGlobalRoleMapper;
import com.xhsj.user.hr.system.mapper.TbGlobalUserMapper;
import com.xhsj.user.utils.StringUtils;
import com.xhsj.user.utils.UserUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.*;

/**
 * <p>
 * 流程-任务审核表 服务实现类
 * </p>
 *
 * @author liuqinghua
 * @since Aug 31, 2020 4:15:14 PM
 */
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
//@CacheConfig(cacheNames = "TbGlobalApprovalTask")
public class TbGlobalApprovalTaskService extends BaseService<TbGlobalApprovalTaskMapper, TbGlobalApprovalTask> {
    @Autowired
    private TbGlobalApprovalTaskMapper dao;

    // 流程节点
    @Autowired
    private TbGlobalWorkFlowNodeMapper processNodeMapper;

    // 流程节点
    @Autowired
    private TbGlobalWorkFlowNodeService tbGlobalWorkFlowNodeService;

    // 用户
    @Autowired
    private TbGlobalUserMapper tbGlobalUserMapper;

    // 角色
    @Autowired
    private TbGlobalRoleMapper tbGlobalRoleMapper;

    // 流程历史
    @Autowired
    private TbGlobalApprovalHiTaskMapper processHiTaskMapper;

    // 流程历史
    @Autowired
    private TbGlobalApprovalHiTaskService processHiTaskService;


	/**
	 * 保存
	 * @author liuqinghua
	 * @date Aug 31, 2020 4:15:14 PM
	 */
    @Override
    //@CacheEvict(cacheNames="TbGlobalApprovalTask", allEntries=true)
    public boolean save(TbGlobalApprovalTask entity) {
        return super.save(entity);
    }

	/**
	 * 通过id获取数据
	 * @author liuqinghua
	 * @date Aug 31, 2020 4:15:14 PM
	 */
    @Override
    //@Cacheable(key = "#id",sync = true)
    public TbGlobalApprovalTask getById(Serializable id) {
        return super.getById(id);
    }

	/**
	 * 通过id删除数据
	 * @author liuqinghua
	 * @date Aug 31, 2020 4:15:14 PM
	 */
    @Override
    //@CacheEvict(cacheNames="TbGlobalApprovalTask", allEntries=true)
    public boolean removeById(Serializable id) {
        return super.removeById(id);
    }

	/**
	 * 批量删除数据
	 * @author liuqinghua
	 * @date Aug 31, 2020 4:15:14 PM
	 */
    //@CacheEvict(cacheNames="SysDict", allEntries=true)
    @Override
    public boolean removeByIds(Collection<? extends Serializable> idList) {
        return super.removeByIds(idList);
    }

	/**
	 * 分页查询数据
	 * @author liuqinghua
	 * @date Aug 31, 2020 4:15:14 PM
	 */
    //@Cacheable(key = "#data",sync = true)
    public IPage<TbGlobalApprovalTask> selectPage(Map<String,Object> data) {
        int currentPage=1;
        if (!Objects.isNull(data.get("page"))) {
            currentPage=(Integer) data.get("page");
        }
        int pageSize=20;
        if (!Objects.isNull(data.get("size"))) {
            pageSize=(Integer) data.get("size");
        }

        TbGlobalApprovalTask entity = JSON.parseObject(JSON.toJSONString(data), TbGlobalApprovalTask.class);
        Page<TbGlobalApprovalTask> page = new Page(currentPage,pageSize);
        QueryWrapper<TbGlobalApprovalTask> wrapper = new QueryWrapper(entity);
        return super.selectPage(page, wrapper);
    }

    // 公共开始流程
    public ProcessNodeQuery startHandleAuditLearningGardenNoLeader(HandleAuditDto data,Long organizationId) throws Exception {
        // 得到节点id和几点名称
        ProcessNodeQuery processNodeVo = new ProcessNodeQuery();
        // 查询初始流程节点
        List<FirstProcessNodeIdQuery> firstProcessNodeIdQuery= processNodeMapper.firstProcessNodeId(data.getApplyType(),organizationId);

        String currentNodeName = null;
        Long currentNodeId = null;
        for (FirstProcessNodeIdQuery firstProcessNodeId :firstProcessNodeIdQuery) {
            currentNodeName = firstProcessNodeId.getNodeName();
            currentNodeId = firstProcessNodeId.getNodeId();
            data.setBusinessId(firstProcessNodeId.getBusinessId());
        }
        this.startSaveCurrentRunAndHisTask(new TbGlobalApprovalTask(),data.getOpinionText(),currentNodeName,currentNodeId);
        LoginUser loginAppUser = UserUtils.getLoginAppUser();
        processNodeVo.setCurrentUserId(loginAppUser.getUserId());
        processNodeVo.setNodeId(0);
        processNodeVo.setNodeName("完结");
        return processNodeVo;
    }

    // 公共开始流程
    public ProcessNodeQuery startHandleAuditLearningGarden(HandleAuditDto data,Long organizationId) throws Exception {
        // 得到节点id和几点名称
        ProcessNodeQuery processNodeVo = new ProcessNodeQuery();
        // 中deal_with字段 0 通过 1 退回 2 重要
        try {
            // 查询初始流程节点
             List<FirstProcessNodeIdQuery> firstProcessNodeIdQuery= processNodeMapper.firstProcessNodeId(data.getApplyType(),organizationId);
            if (firstProcessNodeIdQuery.size()==0) {
                throw new Exception("此部门下无流程节点,请联系管理员添加流程");
            }
            Object nextNodeId = null;
            String nodeName = null;
            String currenNnodeName = null;
            Long currentNodeId = null;
            for (FirstProcessNodeIdQuery firstProcessNodeId :firstProcessNodeIdQuery) {
                    nextNodeId = firstProcessNodeId.getNextNodeId();
                    nodeName = firstProcessNodeId.getNextNodeName();
                    currenNnodeName = firstProcessNodeId.getNodeName();
                    currentNodeId = firstProcessNodeId.getNodeId();
                    data.setBusinessId(firstProcessNodeId.getBusinessId());
            }
            processNodeVo.setUserId(data.getUserId());
            // 获取下一个节点的用户名
            String handler = this.getHandler(data);
            TbGlobalApprovalTask processTask = null;
            // 用户
            if (!Objects.isNull(data.getUserId())) {
                List<Long> split1 = JSONArray.parseArray(String.valueOf(data.getUserId()), Long.class);
                for (Long s : split1) {
                    // 审核参数转正在执行流程表参数
                    data.setUserId(null);
                    processTask = StringUtils.toJavaBean(data, TbGlobalApprovalTask.class);
                    processTask.setUserId(s);
                    processTask.setNodeId(StringUtils.toLong(nextNodeId));
                    processTask.setHandler(handler);
                    // 添加正在执行任务+保存当前节点历史记录+下一个节点的历史记录
                    this.startSaveCurrentRunAndHisTask(processTask,data.getOpinionText(),currenNnodeName,currentNodeId);
                    this.savaRunAndHisTask(processTask,data.getOpinionText(),nodeName);
                }
            }

            LoginUser loginAppUser = UserUtils.getLoginAppUser();
            processNodeVo.setCurrentUserId(loginAppUser.getUserId());
            processNodeVo.setNodeId(StringUtils.toLong(nextNodeId));
            processNodeVo.setNodeName(nodeName);
        } catch (Exception e) {
            log.error("添加流程失败", e);
            throw new Exception(e);
        }
        return processNodeVo;
    }



    // 公共开始流程
    public ProcessNodeQuery startHandleAudit(HandleAuditDto data,Long organizationId) throws Exception {
        // 得到节点id和几点名称
        ProcessNodeQuery processNodeVo = new ProcessNodeQuery();
        // 中deal_with字段 0 通过 1 退回 2 重要
        try {
            // 当前用户的角色id
            List<Long> roleListByUserId = tbGlobalRoleMapper.getRoleListByUserId(data.getCreateBy());
            // 查询初始流程节点
            List<FirstProcessNodeIdQuery> firstProcessNodeIdQuery= processNodeMapper.firstProcessNodeId(data.getApplyType(),organizationId);
            if (firstProcessNodeIdQuery.size() == 0) {
                throw new Exception("此部门下无流程节点,请联系管理员添加流程");
            }

            Object nextNodeId = null;
            Object roleId = null;
            String nodeName = null;
            String currenNnodeName = null;
            Long currentNodeId = null;
            for (FirstProcessNodeIdQuery firstProcessNodeId :firstProcessNodeIdQuery) {
                        if (roleListByUserId.contains(firstProcessNodeId.getRoleId())) {
                            nextNodeId = firstProcessNodeId.getNextNodeId();
                            roleId = firstProcessNodeId.getNextRoleId();
                            nodeName = firstProcessNodeId.getNextNodeName();
                            currenNnodeName = firstProcessNodeId.getNodeName();
                            currentNodeId = firstProcessNodeId.getNodeId();
                            data.setBusinessId(firstProcessNodeId.getBusinessId());
                            break;
                        }
                        if (StringUtils.isNull(firstProcessNodeId.getRoleId())) {
                            nextNodeId = firstProcessNodeId.getNextNodeId();
                            roleId = firstProcessNodeId.getNextRoleId();
                            nodeName = firstProcessNodeId.getNextNodeName();
                            currenNnodeName = firstProcessNodeId.getNodeName();
                            currentNodeId = firstProcessNodeId.getNodeId();
                            data.setBusinessId(firstProcessNodeId.getBusinessId());
                        }
                    }
            if (roleId == null) {
                throw new Exception("此部门下无流程节点,请联系管理员添加流程");
            }
            data.setRoleIds(Arrays.asList(String.valueOf(roleId).split(",")));
            processNodeVo.setRoleIds(data.getRoleIds());
            // 获取下一个节点的用户名
            String handler = this.getHandler(data);
            TbGlobalApprovalTask processTask = null;
            // 角色
            if (!Objects.isNull(data.getRoleIds())) {
                List<Long> split1 = JSONArray.parseArray(String.valueOf(data.getRoleIds()), Long.class);
                for (Long s : split1) {
                    // 审核参数转正在执行流程表参数
                    data.setRoleIds(null);
                    processTask = StringUtils.toJavaBean(data, TbGlobalApprovalTask.class);
                    processTask.setRoleId(s);
                    processTask.setNodeId(StringUtils.toLong(nextNodeId));
                    processTask.setHandler(handler);
                    // 添加正在执行任务+保存当前节点历史记录+下一个节点的历史记录
                    this.startSaveCurrentRunAndHisTask(processTask,data.getOpinionText(),currenNnodeName,currentNodeId);
                    this.savaRunAndHisTask(processTask,data.getOpinionText(),nodeName);
                }
            }

            LoginUser loginAppUser = UserUtils.getLoginAppUser();
            processNodeVo.setCurrentUserId(loginAppUser.getUserId());
            processNodeVo.setNodeId(StringUtils.toLong(nextNodeId));
            processNodeVo.setNodeName(nodeName);
        } catch (Exception e) {
            log.error("添加流程失败", e);
            throw e;
        }
        return processNodeVo;
    }

    // 添加当前执行任务到历史任务
    public void startSaveCurrentRunAndHisTask(TbGlobalApprovalTask processTask,String opinionText,String currenNnodeName,Long currentNodeId) throws Exception {
        LoginUser loginAppUser = UserUtils.getLoginAppUser();
        TbGlobalApprovalHiTask processHiTask = new TbGlobalApprovalHiTask();
        BeanUtils.copyProperties(processTask,processHiTask);
        processHiTask.setStatus(0);// 已审核
        processHiTask.setCreateBy(processHiTask.getCreateBy());
        processHiTask.setOpinionText(opinionText);
        processHiTask.setUserId(processHiTask.getCreateBy());
        processHiTask.setHandler(loginAppUser.getFullName());
        processHiTask.setRoleId(null);
        processHiTask.setNodeId(currentNodeId);
        processHiTask.setNodeName(currenNnodeName);
        processHiTask.setCreateBy(processHiTask.getCreateBy());
        processHiTask.setCreateDate(new Date(System.currentTimeMillis() - 1000));
        processHiTask.setUpdateDate(processHiTask.getCreateDate());
        int insert = processHiTaskMapper.insert(processHiTask);
        if (insert == 0) {
            log.error("添加当前执行任务到历史任务失败");
            throw new Exception("添加当前执行任务到历史任务失败");
        }
    }

    /**
	 * 查询所有数据
	 * @author liuqinghua
	 * @date Aug 31, 2020 4:15:14 PM
	 */
    @Override
    //@Cacheable(value = "TbGlobalApprovalTask",sync = true)
    public List<TbGlobalApprovalTask> selectAll() {
        return super.selectAll();
    }

    // 公共流程
    public ProcessNodeQuery handleAudit(HandleAuditDto data) throws Exception {
        // 得到节点id和几点名称
        ProcessNodeQuery processNodeVo = new ProcessNodeQuery();
        Object roleIds = null;
        Object auditUserId = null;
        // 中deal_with字段 0 通过 1 退回 2 重要
        try {
            Object nextNodeId =null;
            // 节点名称
            String nodeName = null;
            if (data.getStatus()== 1) {
                // 查询初始流程节点
                QueryWrapper queryWrapper = new QueryWrapper();
                queryWrapper.eq("business_id",data.getBusinessId());
                queryWrapper.eq("approve_order_no",1);
                TbGlobalWorkFlowNode firstProcessNodeIdQuery = tbGlobalWorkFlowNodeService.getOne(queryWrapper);
                nextNodeId = firstProcessNodeIdQuery.getApproveOrderNo();
                nodeName = firstProcessNodeIdQuery.getTaskName();
                data.setUserId(Arrays.asList(String.valueOf(data.getProposerId()).split(",")));
            }else if(data.getStatus()== 0){
                // 查询下一节点
                Map<String, Object> map = getNextNode(data.getNodeId(),data.getBusinessId());
                nextNodeId = map.get("nextNodeId");
                Object roleId = map.get("roleId");
                if (!Objects.isNull(roleId)) {
                    data.setRoleIds(Arrays.asList(String.valueOf(roleId).split(",")));
                }
                nodeName = String.valueOf(map.get("nextNodeName"));
            }
            String handler = "";
            // 获取下一个节点的用户名
            if (!"完结".equals(nodeName) && data.getNodeId() != -11 && data.getStatus() != 3) {
                handler = this.getHandler(data);
            }
            TbGlobalApprovalTask processTask = null;
            if (!Objects.isNull(nextNodeId) && StringUtils.isNotBlank(nextNodeId)) {
                // 用户
                if (!Objects.isNull(data.getUserId())) {
                    auditUserId = data.getUserId();
                    List<Long> split = JSONArray.parseArray(String.valueOf(data.getUserId()), Long.class);
                    for (Long s : split) {
                        // 审核参数转正在执行流程表参数
                        data.setUserId(null);
                        processTask = StringUtils.toJavaBean(data, TbGlobalApprovalTask.class);
                        processTask.setUserId(s);
                        processTask.setNodeId(StringUtils.toLong(nextNodeId));
                        processTask.setHandler(handler);
                        // 添加下一个节点执行任务
                        this.savaRunAndHisTask(processTask,data.getOpinionText(),nodeName);
                    }
                }
                // 角色
                if (!Objects.isNull(data.getRoleIds())) {
                    roleIds = data.getRoleIds();
                    List<Long> split1 = JSONArray.parseArray(String.valueOf(data.getRoleIds()), Long.class);
                    for (Long s : split1) {
                        if (s != 0) {
                        // 审核参数转正在执行流程表参数
                        data.setRoleIds(null);
                        processTask = StringUtils.toJavaBean(data, TbGlobalApprovalTask.class);
                        processTask.setRoleId(s);
                        processTask.setNodeId(StringUtils.toLong(nextNodeId));
                        processTask.setHandler(handler);
                        // 添加正在执行任务
                        this.savaRunAndHisTask(processTask,data.getOpinionText(),nodeName);
                        }
                    }
                }
            }

            long nodeId = StringUtils.toLong(nextNodeId);
            if ("完结".equals(nodeName)) { // 将完结节点添加到历史表
                Long userId = UserUtils.getLoginAppUser().getUserId();
                TbGlobalApprovalHiTask tbGlobalApprovalHiTask = new TbGlobalApprovalHiTask(data.getBusinessId(),data.getDataId(),
                        nodeId,0,nodeName,userId,new Date(),userId,new Date());
                processHiTaskService.save(tbGlobalApprovalHiTask);
            }
            // 修改目前执行的任务+保存意见
            updateRunTask(data);
            // 节点id
            LoginUser loginAppUser = UserUtils.getLoginAppUser();
            Long userId = loginAppUser.getUserId();
            processNodeVo.setRoleIds(data.getRoleIds());
            processNodeVo.setUserId(data.getUserId());
            processNodeVo.setCurrentUserId(userId);
            processNodeVo.setNodeId(nodeId);
            processNodeVo.setUserId(auditUserId);
            processNodeVo.setRoleIds(roleIds);
            processNodeVo.setNodeName(nodeName);
            if (data.getStatus()== 3){
                processNodeVo.setNodeName("作废");
                processNodeVo.setNodeId(0);
                processNodeVo.setDelFlag(1);
            }
        } catch (Exception e) {
            log.error("添加流程失败", e);
            throw new Exception(e);
        }
        return processNodeVo;
    }


    // 获取下一个节点的用户名
    private String getHandler(HandleAuditDto data) throws Exception {
        // 获取下一个节点的用户名根据用户ids
        Set<String> fullNamesByUserId = new HashSet<>();
        if (StringUtils.isNotBlank(data.getUserId())) {
            List<String> userIdList = JSONArray.parseArray(String.valueOf(data.getUserId()), String.class);
            fullNamesByUserId = tbGlobalUserMapper.getFullNameByUserIds(userIdList);
        }
        // 获取下一个节点的用户名根据角色ids
        Set<String> fullNamesByRoleId = new HashSet<>();
        if (StringUtils.isNotBlank(data.getRoleIds())) {
            List<String> roleIdList = JSONArray.parseArray(String.valueOf(data.getRoleIds()), String.class);
            fullNamesByRoleId = tbGlobalUserMapper.getFullNameByRoleIds(roleIdList);
        }
        fullNamesByUserId.addAll(fullNamesByRoleId);
        if (fullNamesByUserId.size() == 0) {
            throw new Exception("下一节点没有审核用户,请联系人事！");
        }
        String handler = Joiner.on(",").join(fullNamesByUserId);
        return handler;
    }

    // 当前节点下一个节点相关的数据
    private Map<String, Object> getNextNode(long nodeId,long businessId) {
        return  processNodeMapper.getNextNode(nodeId,businessId);
    }

    // 保存下一个流程指派人和正在执行任务到历史任务
    public void savaRunAndHisTask(TbGlobalApprovalTask processTask,String opinionText,String nodeName) throws Exception {
        // 保存下一个流程指派人
        boolean saveTask = this.save(processTask);
        if (!saveTask) {
            log.error("保存数据失败");
            throw new Exception("保存数据失败");
        }
        // 添加正在执行任务到历史任务
        if (processTask !=null) {
            TbGlobalApprovalHiTask processHiTask = new TbGlobalApprovalHiTask();
            BeanUtils.copyProperties(processTask,processHiTask);
            processHiTask.setStatus(2);// 未审核
            processHiTask.setUpdateDate(processHiTask.getCreateDate());
            processHiTask.setUpdateBy(processHiTask.getCreateBy());
            processHiTask.setNodeName(nodeName);
            int insert = processHiTaskMapper.insert(processHiTask);
            if (insert == 0) {
                log.error("保存数据失败");
                throw new Exception("保存数据失败");
            }
        }
    }

    // 修改目前执行的任务
    private void updateRunTask(HandleAuditDto data) throws Exception {
        // 修改目前执行的任务
        if (StringUtils.isNotBlank(data.getProcessTaskId())) {
            Long s = data.getProcessTaskId();
            // 删除正在执行任务
            int row1 = dao.deleteTaskById(s);
            if (row1 == 0) {
                log.error("保存数据失败");
                throw new Exception("保存数据失败");
            }
            // 修改历史表处理人+保存意见
            updateHiTask(data);
        }
    }

    // 修改目前执行的任务
    private void updateHiTask(HandleAuditDto data) throws Exception {
            Long s = data.getProcessTaskId();
            // 修改历史表处理人
            TbGlobalApprovalHiTask processHiTask = new TbGlobalApprovalHiTask();
            processHiTask.setId(s);
            processHiTask.setUserId(UserUtils.getLoginAppUser().getUserId());
            processHiTask.setHandler(UserUtils.getLoginAppUser().getFullName());
            processHiTask.setRoleId(null);
            processHiTask.setUpdateDate(new Date());
            processHiTask.setOpinionText(data.getOpinionText());
            processHiTask.setStatus(data.getStatus());
            boolean update = processHiTaskService.updateById(processHiTask);
            if (!update) {
                log.error("保存数据失败");
                throw new Exception("保存数据失败");
            }
        }

    public void delById(Long processTaskId) {
        dao.deleteTaskById(processTaskId);
    }

    /**
     * 首页hr系统管理消息
     * @author liuqinghua
     * @date Aug 31, 2020 4:15:14 PM
     */
    public IPage<HrMessageQuery> getHrMessage(PageDto data) {
        Page<HrMessageQuery> page = new Page<>(data.getPage(),data.getSize());
        LoginUser loginAppUser = UserUtils.getLoginAppUser();
        Long userId = loginAppUser.getUserId();
        // 获取用户角色id
        List<Long> roleList = tbGlobalRoleMapper.getRoleListByUserId(userId);

        return dao.getHrMessage(page,userId,roleList);
    }

    /**
     * 首页hr系统管理消息待办
     * @author liuqinghua
     * @date Aug 31, 2020 4:15:14 PM
     */
    public IPage<HrMessageQuery> getHrMessageCommission(PageDto data) {
        Page<HrMessageQuery> page = new Page<>(data.getPage(),data.getSize());
        return dao.getHrMessageCommission(page);
    }

    /**
     * 首页hr系统管理不分页
     * @author liuqinghua
     * @date Aug 31, 2020 4:15:14 PM
     */
    public List<HrMessageQuery> getHrMessageCommissionNotPage() {
        return dao.getHrMessageCommissionNotPage();
    }


    /**
     * 首页hr系统管理消息代办数
     * @author liuqinghua
     * @date Aug 31, 2020 4:15:14 PM
     */
    public Integer getHrMessageCommissionNum() {
        return dao.getHrMessageCommissionNum();
    }

    /**
     * 首页hr系统管理消息审核数
     * @author liuqinghua
     * @date Aug 31, 2020 4:15:14 PM
     */
    public Integer getHrMessageNum() {
        LoginUser loginAppUser = UserUtils.getLoginAppUser();
        Long userId = loginAppUser.getUserId();
        // 获取用户角色id
        List<Long> roleList = tbGlobalRoleMapper.getRoleListByUserId(userId);
        return dao.getHrMessageNum(userId,roleList);
    }

    /**
     * 判断是否有正在执行的流程
     * @param businessId
     * liuqinghua
    */
    public List<Long> getRunTask(Long businessId) {
     return dao.getRunTask(businessId);
    }

    public void delHisTask(Long businessId, Long dataId) {
        dao.delHisTask(businessId,dataId);
    }
}



